package com.atguigu.gmall.web.controller;

import com.atguigu.gmall.item.client.ItemFeignClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;

import java.util.Map;

@Controller
public class ItemController {
    @Autowired
    private ItemFeignClient itemFeignClient;
    @GetMapping("/{skuId}.html")
    public  String getItem(@PathVariable("skuId") Long skuId, Model model){
        //调用详情微服务获取渲染详情页所有的数据
        Map<String, Object> itemAllData = itemFeignClient.getItemAllData(skuId);
        model.addAllAttributes(itemAllData);
        return "/item/item";
    }
}
